// 加载全局样式样式
import './styles/vui.scss'

// 加载 VuiIcon
import VuiIcon from './icons/index'
import './icons/icons.css'

export function setupVui(app) {
  console.log(VERSION) // eslint-disable-line
  app.component('VuiIcon', VuiIcon)
  // 加载主题
  const Themes = require.context('./styles/themes', false, /\.scss$/)
  Themes.keys().map(Themes)

  // 加载插件
  const PluginsCommon = require.context(`./plugins/common`, false, /\.js$/)
  PluginsCommon.keys().forEach((key) => PluginsCommon(key).setup(app))

  const Plugins = require.context(`./plugins/${process.env.VUE_APP_BuildProjectType}`, false, /\.js$/)
  Plugins.keys().forEach((key) => Plugins(key).setup(app))

  // console.log('加载插件', Plugins.keys(), process.env.VUE_APP_BuildProjectType)
  // 加载组件
  const Components = require.context('.', true, /\.vue$/)
  Components.keys()
    .map(Components)
    .forEach((item) => {
      if (item.default.name && item.default.name !== 'Layouts') {
        app.component(item.default.name, item.default)
      }
    })
}
